package com.example.back.controller;

import com.example.back.entity.ShouCang;
import com.example.back.service.ShouCangService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;
import java.util.ArrayList;

@RestController
public class ShouCangController {
    @Autowired
    private ShouCangService shouCangService;

    @PostMapping("/shouCang")
    public int addShouCang(ShouCang shouCang){
        return shouCangService.addShouCang(shouCang);
    }

    @DeleteMapping("/shouCang/{id}")
    public int deleteShouCangById(@PathVariable("id") Serializable id){
        return shouCangService.deleteShouCangById(id);
    }

    @PutMapping("/shouCang")
    public int updateShouCang(ShouCang shouCang){
        return shouCangService.updateShouCang(shouCang);
    }

    @GetMapping("/shouCang/{id}")
    public ShouCang selectShouCangById(@PathVariable("id") Serializable id){
        return shouCangService.selectShouCangById(id);
    }

    @GetMapping("/shouCang")
    public ArrayList<ShouCang> selectShouCang(ShouCang shouCang){
        return shouCangService.selectShouCang(shouCang);
    }
}
